<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RabbitMQ 持久化与消息可靠性深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .content-card {
            background: rgba(255, 255, 255, 0.95);
            backdrop-filter: blur(10px);
            transition: all 0.3s ease;
        }
        
        .content-card:hover {
            transform: translateY(-2px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .code-block {
            background: #1e1e1e;
            color: #d4d4d4;
            border-radius: 8px;
            padding: 20px;
            overflow-x: auto;
            font-family: 'Consolas', 'Monaco', monospace;
            font-size: 14px;
            line-height: 1.6;
            position: relative;
        }
        
        .code-block::before {
            content: attr(data-lang);
            position: absolute;
            top: 8px;
            right: 12px;
            font-size: 12px;
            color: #858585;
            text-transform: uppercase;
        }
        
        .feature-card {
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            border: 1px solid rgba(255, 255, 255, 0.8);
            transition: all 0.3s ease;
        }
        
        .feature-card:hover {
            transform: translateY(-5px);
            box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
        }
        
        .mermaid {
            display: flex;
            justify-content: center;
            margin: 30px 0;
        }
        
        .highlight-text {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: 600;
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .info-box {
            background: linear-gradient(135deg, #f3e7e9 0%, #e3eeff 99%, #e3eeff 100%);
            border-left: 4px solid #667eea;
            padding: 20px;
            margin: 20px 0;
            border-radius: 8px;
        }
        
        .list-item::before {
            content: '▸';
            color: #667eea;
            font-weight: bold;
            margin-right: 8px;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 animate-pulse">
                    RabbitMQ 持久化与消息可靠性
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    深入探索分布式系统中的消息队列核心技术
                </p>
                <div class="flex justify-center space-x-6 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-shield-alt mr-2"></i>
                        <span>高可靠性</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-database mr-2"></i>
                        <span>数据持久化</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-rocket mr-2"></i>
                        <span>性能优化</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16">
        <div class="container mx-auto px-6">
            <div class="content-card rounded-xl shadow-2xl p-10">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">在</span>微服务架构和高并发系统中，消息队列作为解耦和异步处理的核心组件，已经成为我们设计高可用、高吞吐系统时不可或缺的一部分。而在这些系统中，如何保证消息的可靠传递，如何确保系统中的数据即使发生故障也能安全持久化，是我们需要深入思考和解决的难题。
                </p>
                <div class="mt-8 text-center">
                    <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737794548338-8b919d9a-cb4c-4903-9bdc-9b38c300fd6d.png" 
                         alt="RabbitMQ Architecture" 
                         class="inline-block rounded-lg shadow-lg max-w-full">
                </div>
                <p class="text-lg leading-relaxed text-gray-700 mt-8">
                    RabbitMQ作为目前最流行的消息队列中间件之一，它在保证高效通信的同时，也为我们提供了强大的消息持久化和可靠性机制。持久化技术可以确保消息即使在系统崩溃或重启的情况下依然不会丢失，保证了数据的安全。而消息的可靠性机制，则确保了消息能够准确无误地送达消费者，并且在整个过程中，消息的传递、消费都能够达到幂等性和顺序性要求。
                </p>
            </div>
        </div>
    </section>

    <!-- RabbitMQ Overview -->
    <section class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <h2 class="text-4xl font-bold text-center mb-12 highlight-text">RabbitMQ 概述</h2>
            
            <div class="grid md:grid-cols-2 gap-8">
                <div class="content-card rounded-xl shadow-xl p-8">
                    <h3 class="text-2xl font-semibold mb-4 section-title">什么是 RabbitMQ</h3>
                    <p class="text-gray-700 leading-relaxed">
                        RabbitMQ 是一个广泛使用的开源消息中间件，基于 AMQP（Advanced Message Queuing Protocol，高级消息队列协议）标准实现。它能够支持异步消息传递、消息队列管理、消息持久化以及高效的消息分发等功能，是现代分布式系统中不可或缺的基础组件之一。
                    </p>
                </div>
                
                <div class="content-card rounded-xl shadow-xl p-8">
                    <h3 class="text-2xl font-semibold mb-4 section-title">核心优势</h3>
                    <ul class="space-y-3">
                        <li class="list-item text-gray-700">高可用性：通过集群模式和镜像队列实现</li>
                        <li class="list-item text-gray-700">可扩展性：支持通过增加节点扩展集群规模</li>
                        <li class="list-item text-gray-700">持久化机制：确保消息在系统重启后不丢失</li>
                        <li class="list-item text-gray-700">多协议支持：AMQP、STOMP、MQTT、HTTP等</li>
                        <li class="list-item text-gray-700">消息确认与可靠性：发布确认和消息确认机制</li>
                    </ul>
                </div>
            </div>
            
            <div class="mt-12">
                <img src="https://cdn.nlark.com/yuque/0/2025/png/21449790/1737794572376-fe4424a5-f239-4b8c-946b-37d4ca685dc1.png" 
                     alt="RabbitMQ Workflow" 
                     class="w-full rounded-lg shadow-xl">
            </div>
        </div>
    </section>

    <!-- Core Components Visualization -->
    <section class="py-16">
        <div class="container mx-auto px-6">
            <h2 class="text-4xl font-bold text-center mb-12">核心组件架构</h2>
            
            <div class="mermaid">
                graph TB
                    P[生产者 Producer] -->|发送消息| E[交换机 Exchange]
                    E -->|路由规则| Q1[队列 Queue 1]
                    E -->|路由规则| Q2[队列 Queue 2]
                    E -->|路由规则| Q3[队列 Queue 3]
                    Q1 -->|拉取消息| C1[消费者 Consumer 1]
                    Q2 -->|拉取消息| C2[消费者 Consumer 2]
                    Q3 -->|拉取消息| C3[消费者 Consumer 3]
                    
                    style P fill:#667eea,stroke:#fff,stroke-width:2px,color:#fff
                    style E fill:#764ba2,stroke:#fff,stroke-width:2px,color:#fff
                    style Q1 fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style Q2 fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style Q3 fill:#f093fb,stroke:#fff,stroke-width:2px,color:#fff
                    style C1 fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
                    style C2 fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
                    style C3 fill:#4facfe,stroke:#fff,stroke-width:2px,color:#fff
            </div>
            
            <div class="grid md:grid-cols-3 gap-6 mt-12">
                <div class="feature-card rounded-lg p-6">
                    <div class="text-3xl mb-4 text-purple-600">
                        <i class="fas fa-exchange-alt"></i>
                    </div>
                    <h4 class="text-xl font-semibold mb-2">交换机类型</h4>
                    <ul class="text-gray-700 space-y-2">
                        <li><strong>Direct</strong>: 精确匹配路由键</li>
                        <li><strong>Fanout</strong>: 广播到所有队列</li>
                        <li><strong>Topic</strong>: 主题模式匹配</li>
                        <li><strong>Headers</strong>: 消息头匹配</li>
                    </ul>
                </div>
                
                <div class="feature-card rounded-lg p-6">
                    <div class="text-3xl mb-4 text-purple-600">
                        <i class="fas fa-layer-group"></i>
                    </div>
                    <h4 class="text-xl font-semibold mb-2">队列特性</h4>
                    <ul class="text-gray-700 space-y-2">
                        <li>FIFO 先进先出</li>
                        <li>支持持久化存储</li>
                        <li>可设置优先级</li>
                        <li>支持镜像队列</li>
                    </ul>
                </div>
                
                <div class="feature-card rounded-lg p-6">
                    <div class="text-3xl mb-4 text-purple-600">
                        <i class="fas fa-check-double"></i>
                    </div>
                    <h4 class="text-xl font-semibold mb-2">消息确认</h4>
                    <ul class="text-gray-700 space-y-2">
                        <li>生产者确认机制</li>
                        <li>消费者手动确认</li>
                        <li>自动确认模式</li>
                        <li>批量确认优化</li>
                    </ul>
                </div>
            </div>
        </div>
    </section>

    <!-- Message Persistence -->
    <section class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <h2 class="text-4xl font-bold text-center mb-12 highlight-text">消息持久化机制</h2>
            
            <div class="content-card rounded-xl shadow